package com.pansoft.openplanet.bean;

import java.io.Serializable;
import java.util.Objects;

/**
 * 代币 对象
 */
public class AssetListBean implements Serializable {
    private String blockChainID;//所属区块链ID，如ETH是2，BTC是1，EOS是3 PWR 4
    private String id;
    private Object icon;
    private String name;//简写名
    private String secondName;//全名
    private String address;
    private int tokenDecimals;//位数
    private String balance;//余额
    private boolean isSelected;

    //type 0 默认item 数据   1 表示header  2 footer
    private  int type ;

    public AssetListBean() {
    }

    private AssetListBean(Builder builder) {
        setBlockChainID(builder.blockChainID);
        setId(builder.id);
        setIcon(builder.icon);
        setName(builder.name);
        setSecondName(builder.secondName);
        setAddress(builder.address);
        setTokenDecimals(builder.tokenDecimals);
        setBalance(builder.balance);
        setSelected(builder.isSelected);
        setType(builder.type);
    }

    public String getBlockChainID() {
        return blockChainID;
    }

    public AssetListBean setBlockChainID(String blockChainID) {
        this.blockChainID = blockChainID;
        return this;
    }

    public String getId() {
        return id;
    }

    public AssetListBean setId(String id) {
        this.id = id;
        return this;
    }

    public Object getIcon() {
        return icon;
    }

    public AssetListBean setIcon(Object icon) {
        this.icon = icon;
        return this;
    }

    public String getName() {
        return name;
    }

    public AssetListBean setName(String name) {
        this.name = name;
        return this;
    }

    public String getSecondName() {
        return secondName;
    }

    public AssetListBean setSecondName(String secondName) {
        this.secondName = secondName;
        return this;
    }

    public String getAddress() {
        return address;
    }

    public AssetListBean setAddress(String address) {
        this.address = address;
        return this;
    }

    public int getTokenDecimals() {
        return tokenDecimals;
    }

    public AssetListBean setTokenDecimals(int tokenDecimals) {
        this.tokenDecimals = tokenDecimals;
        return this;
    }

    public String getBalance() {
        return balance;
    }

    public AssetListBean setBalance(String balance) {
        this.balance = balance;
        return this;
    }

    public boolean isSelected() {
        return isSelected;
    }

    public AssetListBean setSelected(boolean selected) {
        isSelected = selected;
        return this;
    }

    public int getType() {
        return type;
    }

    public AssetListBean setType(int type) {
        this.type = type;
        return this;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        AssetListBean that = (AssetListBean) obj;
        return Objects.equals(name, that.name) &&
                Objects.equals(address, that.address);
    }


    @Override
    public int hashCode() {
        return name.hashCode() + address.hashCode();
    }



//    public JSONObject toJSON() {
//        try {
//            JSONObject jsonObject = new JSONObject();
//            jsonObject.put("icon", icon);
//            jsonObject.put("name", name);
//            jsonObject.put("secondName", secondName);
//            jsonObject.put("address", address);
//            jsonObject.put("balance", balance);
//            jsonObject.put("isSelected", isSelected);
//            return jsonObject;
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//       return null;
//    }

    public static final class Builder {
        private String blockChainID;
        private String id;
        private Object icon;
        private String name;
        private String secondName;
        private String address;
        private int tokenDecimals;
        private String balance;
        private boolean isSelected;
        private int type;

        public Builder() {
        }

        public Builder blockChainID(String val) {
            blockChainID = val;
            return this;
        }

        public Builder id(String val) {
            id = val;
            return this;
        }

        public Builder icon(Object val) {
            icon = val;
            return this;
        }

        public Builder name(String val) {
            name = val;
            return this;
        }

        public Builder secondName(String val) {
            secondName = val;
            return this;
        }

        public Builder address(String val) {
            address = val;
            return this;
        }

        public Builder tokenDecimals(int val) {
            tokenDecimals = val;
            return this;
        }

        public Builder balance(String val) {
            balance = val;
            return this;
        }

        public Builder isSelected(boolean val) {
            isSelected = val;
            return this;
        }

        public Builder type(int val) {
            type = val;
            return this;
        }

        public AssetListBean build() {
            return new AssetListBean(this);
        }
    }
}
